package com.yanqu.road.server.cmd.activity.sonhai.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.SonHaiProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.fund.ActivityFundModule;
import com.yanqu.road.server.manger.activity.fund.ActivityFundMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = SonHaiProto.SonHaiSyncTeamScoreFromCrossReqMsg.class, respMsg = SonHaiProto.SonHaiSyncTeamScoreFromCrossReqMsg.class)
@Cmd(code = Protocol.S_SON_HAI_SYNC_TEAM_SCORE_END_ACTIVITY_FROM_CROSS,desc = "山海伏兽-活动结束-更新玩家队友积分-跨服返回")
public class SonHaiTeamScoreChangeEndActivityFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        SonHaiProto.SonHaiSyncTeamScoreFromCrossReqMsg reqMsg = SonHaiProto.SonHaiSyncTeamScoreFromCrossReqMsg.parseFrom(packet.getBytes());
        int activityId = reqMsg.getActivityId();
        for (SonHaiProto.SonHaiSyncTeamScoreUserItem item : reqMsg.getUsersList()) {
            //更新玩家队伍积分
            ActivityFundMgr.updateProgress(activityId, item.getUserId(), item.getTeamScore());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
